package org.wjk.handler;

import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;
import org.wjk.pojo.vo.ResponseRes;
import org.wjk.utils.ResponseUtils;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@Component
public class MyAuthenticationEntryPoint implements AuthenticationEntryPoint {
    @Override
    public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException {
        /*提示用户，您未登录本系统，请先登录！*/
        ResponseUtils.convertToJson(response, ResponseRes.failure(5001,"您未登录本系统，请先登录！",null));
    }
}
